#!/usr/bin/env python3
"""
Gitee仓库配置验证脚本
"""
import json
import os
from pathlib import Path

def verify_gitee_setup():
    """验证Gitee仓库配置"""
    print("🔍 开始验证Gitee仓库配置...")
    
    # 检查必要目录
    required_dirs = [
        'config',
        'data/site-A', 
        'data/site-B',
        'data/merged/daily',
        'data/merged/monthly',
        'backups',
        'reports/site-A',
        'reports/site-B', 
        'reports/company',
        'scripts'
    ]
    
    for dir_path in required_dirs:
        if not os.path.exists(dir_path):
            print(f"❌ 缺失目录: {dir_path}")
            return False
        print(f"✅ 目录存在: {dir_path}")
    
    # 检查配置文件
    required_configs = [
        'config/sites.json',
        'config/users.json', 
        'config/sync_config.json'
    ]
    
    for config_file in required_configs:
        if not os.path.exists(config_file):
            print(f"❌ 缺失配置文件: {config_file}")
            return False
        
        # 验证JSON格式
        try:
            with open(config_file, 'r', encoding='utf-8') as f:
                json.load(f)
            print(f"✅ 配置文件有效: {config_file}")
        except json.JSONDecodeError as e:
            print(f"❌ 配置文件格式错误 {config_file}: {e}")
            return False
    
    print("🎉 Gitee仓库配置验证通过！")
    return True

if __name__ == "__main__":
    verify_gitee_setup()